<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html class="s1">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Reader demo HTML document</title>
  <body>
	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
	<script type="text/javascript">
		function Fm (config){
			this.list = config.list;
			this.listInfo = config.listInfo;
			this.fm = null;
			
		};
		Fm.prototype = {
			currentIndex : 1,
			init : function(){
				var fm = new Audio(this.list[0]);
				this.fm = fm;
			},
			play : function(idx){
				this.fm.src = this.list[idx];
				this.fm.play();
			},
			paused : function(){
				this.fm.pause();
			},
			
		};
	
	</script>
$(function() {
	var fm_list = ['fm/1.mp3','fm/2.mp3','fm/3.mp3','fm/4.mp3','fm/5.mp3','fm/6.mp3'];
	var fm_info = [
		'王菲 - 红豆 - 04:16',
		'王菲 - 幽兰操 - 04:33',
		'王菲 - 流年 - 04:33',
		'王菲 - 人间 - 04:33',
		'王菲 - 但愿人长久 - 04:33',
		'王菲 - 传奇 - 04:33'
	];
	var fm = new Audio(fm_list[0]);
	//console.log(fm.duration);
	var fm_index = 0;
	// Get the play button and append an audio play method to onclick
	$('#fm-play').click(function(e){
		if(fm.paused){
			fm.play();
			$('#fm-play').html('暂停');
			$('#fm-next').show();
			$('#fm-panel').html(fm_info[fm_index]);
		}else{
			fm.pause();
			$('#fm-play').html('播放');
			$('#fm-next').hide();
			$('#fm-panel').html('暂停中.......');
		}
		return false;
	});
	
	// Get where one are in playback and push the time to an element
	fm.addEventListener("timeupdate", function() {
	    var duration = document.getElementById('fm-duration');
	    var s = parseInt(fm.currentTime % 60);
	    var m = parseInt((fm.currentTime / 60) % 60);
	    duration.innerHTML = m + ':' + s + 'sec';
	}, false);
	
	fm.addEventListener('ended', function () {
		//console.log(fm.ended);
		if(fm.index >= fm_list.length-1){
			fm_index = 0;
		}else{
			fm_index += 1;
		}
	    fm.src = fm_list[fm_index];
	    fm.play();
	    $('#fm-panel').html(fm_info[fm_index]);
	    //console.log(fm_index);
	});
	$('#fm-next').click(function(){
		if(fm_index >= fm_list.length-1){
			fm_index = 0;
		}else{
			fm_index += 1;
		}
		//console.log(fm_index);
	    fm.src = fm_list[fm_index];
	    fm.play();
	    $('#fm-panel').html(fm_info[fm_index]);
	    $('#fm-next').show();
	    //console.log(fm_index);
	});
});